home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2095 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.5 KB  |  57 lines

  1. Newsgroups: comp.lang.c++
  2. Path: twisto.eng.hou.compaq.com!news
  3. From: Saurabh Dixit <saurabhd@bangate.compaq.com>
  4. Subject: Doesn't work, Why EXACTLY?
  5. Message-ID: <30FA8289.7AD6@bangate.compaq.com>
  6. Sender: news@twisto.eng.hou.compaq.com (System Administrator)
  7. Mime-Version: 1.0
  8. X-Mailer: Mozilla 2.0b2 (Windows; I; 32bit)
  9. Content-Type: text/plain; charset=us-ascii
  10. Organization: Compaq Computer Corporation
  11. Date: Mon, 15 Jan 1996 16:36:25 GMT
  12. X-Nntp-Posting-Host: 172.18.176.8
  13. Content-Transfer-Encoding: 7bit
  14.  
  15. class X {
  16. };
  17. class Y : public X {
  18. };
  19.  
  20. class Base {
  21. public:
  22.     void func1(int a);
  23.     void func2(X* x);
  24. };
  25.  
  26. class Derived : public Base {
  27. public:
  28.     void func1(float b);
  29.     void func2(Y* y);
  30. };
  31.  
  32. when I call func2 from a Derived object with a pointer
  33. to an X object, i get - "... cannot convert from X to Y...".
  34. So looks like compiler looks at method func2() in Derived
  35. class.  I would think the signature of the call would make
  36. it look in Base class.
  37. On the lines of func1() i thought it would work.
  38. Please note that I don't want func2() to be virtual.
  39. I need func2() to do to distinct operations depending on
  40. what type of object was fed to it?
  41.  
  42. Can anyone please explain FULLY?!?!?!
  43. thanks in advance
  44. saurabh
  45.  
  46. -- 
  47. Saurabh Dixit
  48. "All opinions are always my own..."
  49. Compaq Computer Corporation
  50. --------------------------------------------------------------
  51. ----------
  52. Thou who sneezes without kerchief takes matters in own hands.
  53.             - SomeoneIOnceNew
  54. --------------------------------------------------------------
  55. ---------- 
  56. xxxx
  57.